package version2024.easy;

import java.util.Scanner;

/**
 * @author sunhl
 * @Description: HJ6 质数因子
 * @Date: created in 2025/1/11 星期六 15:34
 * @Modified By:
 */
public class HJ6_PrimeFactor {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNext()) { // 注意 while 处理多个 case
            long num = in.nextLong();
            // 求num的开平方根, 后面循环到k即可, 否则如果输入的数过大, 有的用例会超时
            long k = (long) Math.sqrt(num);

            StringBuilder sb = new StringBuilder();

            for (long i = 2; i <= k; i++) {
                // 如果num能被i整除, i作为质因子保存, num/i进行后续计算
                while (num % i == 0) {
                    sb.append(i + " ");
                    num /= i;
                }
            }
            if (num != 1) {
                sb.append(num + "");
            }

            System.out.println(sb.toString());
        }
    }
}
